﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MediaPortal.GUI.Library;

namespace Burn4You
{
    public class Extension : GUIWindow
    {

        public IExtension ExtInterface;
        public int ID;

        /// <summary>
        /// Use this for anything you need to setup. This is only called when the Burn4You plugin is first shown, not at MP start up.
        /// This is the recommended spot for getting the file list. 
        /// </summary>
        public virtual void InitExtension()
        {

        }

        /// <summary>
        /// Called when the extension should show show its interface.
        /// </summary>
        public virtual PluginReturnInfo Run()
        {
            PluginReturnInfo PI = new PluginReturnInfo();
            PI.Completed = false;

            return PI;
        }

        /// <summary>
        /// This function should return all the files the extension can find. It is used for allowing the user to burn those files directly to disk as files.
        /// The first value should be the full path to the file. The second value should specifiy the BurnType, eg "TV Show" or "Movie", etc.
        /// </summary>
        /// <returns></returns>
        public virtual List<BurnFile> GetFiles()
        {
            List<BurnFile> Files = new List<BurnFile>();
            return Files;
        }

        public static bool GetExtension(int id, ref Extension returnext)
        {
            foreach (Extension ext in  Burn4YouPlugin.ExtHandler.Extensions)
            {
                if (id == ext.ID)
                {
                    Utils.Burn4YouLog.Write("Got extension \"" + ext.ExtInterface.ExtName +"\"");
                    returnext = ext;
                    return true;
                }
            }

            return false;
        }
    }
}
